package com.qingke.spring3.demo7;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

/**
 * �����ࣺ�����е�����ǿ���
 * @author qingke04
 *
 */
@Aspect
public class MyAspect {

	public MyAspect() {
		// TODO Auto-generated constructor stub
	}
	@Before("execution(* com.qingke.spring3.demo7.UserDao.add(..))")
	public void before(){
		System.out.println("前置增强......");
	}
	
	@AfterReturning(value="execution(* com.qingke.spring3.demo7.UserDao.update(..))",returning="returnVal")
	public void afterReturn(Object returnVal){
		System.out.println("后置增强.......方法返回值"+returnVal);
	}
	@Around("MyAspect.myPointcut()")
	public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{
		System.out.println("环绕前增强..........");
		Object obj=proceedingJoinPoint.proceed();
		System.out.println("环绕后增强..........");
		return obj;
	}
	
	@AfterThrowing(value="MyAspect.myPointcut()",throwing="e")
	public void afterThrow(Throwable e){
		System.out.println("不好了出异常了！！！"+e.getMessage());
	}
	@After("MyAspect.myPointcut()")
	public void after(){
		System.out.println("最终通知..........");
	}
	@Pointcut("execution(* com.qingke.spring3.demo7.UserDao.find(..))")
	private void myPointcut(){}
}
